package com.medical.service.impl;

import com.medical.mapper.DailyConsumptionMapper;
import com.medical.pojo.DailyConsumption;
import com.medical.pojo.DailyVO;
import com.medical.service.DailyConsumptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class DailyConsumptionServiceImpl implements DailyConsumptionService {

    @Autowired
    private DailyConsumptionMapper dailyConsumptionMapper;

    @Override
    public List<DailyConsumption> findAll(DailyVO dailyVO) {
        return dailyConsumptionMapper.findAll(dailyVO);
    }

    @Override
    public List<String> findJoint(DailyVO dailyVO) {
        List<DailyConsumption> list = dailyConsumptionMapper.findAll(dailyVO);
        List<String> joints = list.stream().map(DailyConsumption::getJoint).distinct().collect(Collectors.toList());
        return joints;
    }

    @Override
    public List<String> findUsage(DailyVO dailyVO) {
        List<DailyConsumption> list = dailyConsumptionMapper.findAll(dailyVO);
        List<String> usages = list.stream().map(DailyConsumption::getUsage).collect(Collectors.toList());
        return usages;
    }
}
